package com.zb.utils;

import com.zb.enums.DeviceType;
import com.zb.service.ZjSystemLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @Author WEN
 * @Date 2023/7/21 0021
 **/
@Component
public class LoginLogUtil {
    @Resource
    private ZjSystemLoginLogService loginLogService;
    private static LoginLogUtil loginLogUtil;

    @PostConstruct
    public void init() {
        this.loginLogUtil = this;
        this.loginLogUtil.loginLogService = loginLogService;
    }

    /**
     * PC端登录
     * @param account 登录账号或手机号
     * @param browserDevice 浏览器设备
     * @param mode 登录方式
     * @param  ip 登录IP
     */
    public static void pcLoginSuccess(String account, String browserDevice, String mode, String ip) {
        loginLogUtil.loginLogService.loginSuccess(account, 1, browserDevice,  mode, ip);
    }

    /**
     * 移动端网点登录
     * @param account 登录账号或手机号
     * @param browserDevice 浏览器设备
     * @param mode 登录方式
     * @param  ip 登录IP
     */
    public static void networkMobileLoginSuccess(String account, String browserDevice, String mode, String ip) {
        loginLogUtil.loginLogService.loginSuccess(account, 2, browserDevice, mode, ip);
    }

    /**
     * 仓库移动端登录
     * @param account 登录账号或手机号
     * @param browserDevice 浏览器设备
     * @param mode 登录方式
     * @param  ip 登录IP
     */
    public static void storeMobileLoginSuccess(String account, String browserDevice, String mode, String ip) {
        loginLogUtil.loginLogService.loginSuccess(account, 2, browserDevice, mode, ip);
    }

    /**
     * PC端登录失败
     * @param account 登录账号或手机号
     * @param browserDevice 浏览器设备
     * @param mode 登录方式
     * @param  ip 登录IP
     * @param message 登录失败消息
     */
    public static void pcLoginError(String account, String browserDevice, String mode, String ip, String message) {
        loginLogUtil.loginLogService.loginError(account, 1, browserDevice,  mode, ip, message);
    }

}
